<template>
  <el-dialog :visible.sync="visible" v-dialogDrag :title="title" :close-on-click-modal="false" class="tl-dialog" width="800px" @open="open" @close="close" :append-to-body="true" :modal-append-to-body="true">
    <el-form class="tl-form" ref="form" :model="model" :rules="rules" label-width="120px" :disabled="disableEditSubmit">
      <el-row>
        <el-col :span="12">
          <el-form-item label="会议开始时间" prop="meetBegintime">
            <el-date-picker v-model="meetBegintime" type="datetime" placeholder="开始时间" format="yyyy-MM-dd HH:mm" :disabled="true"></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="会议结束时间" prop="meetEndtime">
            <el-date-picker v-model="meetEndtime" type="datetime" placeholder="结束时间" format="yyyy-MM-dd HH:mm" :disabled="true"></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="会议议题" prop="name" :rules="rules.validateRequire">
            <el-input v-model="model.name"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="汇报人姓名" prop="reportusername" :rules="rules.validateRequire">
            <tl-ref-list v-model="model.reportusercode" :initDisplayData.sync="model.reportusername" dataType="code" refTitle="汇报人选择"
                         :externalQueryParam="usersParam" :queryDataUrl="url.queryUserList" :singleSelect="false"></tl-ref-list>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="汇报开始时间" prop="reportbegintimedate">
            <el-date-picker v-model="model.reportbegintimedate" type="date" placeholder="开始时间" value-format="yyyy-MM-dd"></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="" label-width="10px" prop="reportbegintimetime">
            <el-time-select
              v-model="model.reportbegintimetime"
              placeholder="选择时间"
              editable
              :clearable="false"
              :picker-options="{
                start: '00:00',
                step: '00:05',
                end: '24:00'
              }"
            >
            </el-time-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="汇报时长" prop="reportminutes" :rules="rules.validateIntGteZero">
            <el-input v-model="model.reportminutes">
              <template slot="append">
                分钟
              </template>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="汇报内容" prop="preparematerial">
            <el-input v-model="model.preparematerial" type="textarea" :rows="4" maxlength="500"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="议程序号" prop="sortcode">
            <el-input v-model="model.sortcode"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button :type="disableEditSubmit === false ? 'text' : 'primary'" @click="doCancelEdit">取消</el-button>
      <el-button type="primary" @click="doSubmitEdit" :loading="saveLoading" v-if="disableEditSubmit === false">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
/** mixins */
import { mixin_edit } from '@tapui/mixins/mixin_edit'
/** 子组件 */
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from '@tapui/utils/http'
/** VUE配置 */
export default {
  mixins: [mixin_edit],
  components: {},
  data() {
    return {
      moduleTitle: '会议议程',
      urlPrefix: '/meet/agenda/',
      url: {
        // 额外的url
        queryUserList: '/base/permissionManage/queryUserListByShareType'
      },
      usersParam: {}
    }
  },
  props: {
    // 是否是从菜单页面进入的
    isFromMenu: {
      type: Boolean,
      default: true
    },
    sourceMeetID: {
      type: [Number, String],
      default: ''
    },
    meetBegintime: {
      type: String,
      default: ''
    },
    meetEndtime: {
      type: String,
      default: ''
    },
    tempUsersParam: {
      type: Object,
      default: function() {
        return {}
      }
    }
  },
  watch: {
    tempUsersParam: {
      deep: true,
      handler(newValue, oldValue) {
        this.setUsersParam(newValue)
      }
    }
  },
  methods: {
    loaded() {
      // 页面加载完毕执行
      if (!this.isFromMenu && this.isAdd) {
        this.model.meetid = this.sourceMeetID
      }
      if (!this.isAdd) {
        // 编辑
        let beginArr = this.model.reportbegintime.split(' ')
        this.$set(this.model, 'reportbegintimedate', beginArr[0])
        this.$set(this.model, 'reportbegintimetime', beginArr[1].substring(0, 5))
      } else {
        // 新增
        // let beginArr = this.meetBegintime.split(' ')
        // this.$set(this.model, 'reportbegintimedate', beginArr[0])
        // this.$set(this.model, 'reportbegintimetime', beginArr[1].substring(0, 5))
      }
    },
    beforeSubmit() {
      this.model.reportbegintime = `${this.model.reportbegintimedate} ${this.model.reportbegintimetime}`
      return true
    },
    setUsersParam(val) {
      this.usersParam = val
    }
  },
  mounted() {
    this.setUsersParam(this.tempUsersParam)
  }
}
</script>
